package cz.cizek.tutorials.designpatterns.immutableobject.immutable;

/**
 * @author jcizek
 */
public class Fraction {

    private final int numerator;
    private final int denominator;

    public Fraction(int numerator, int denominator) {
        this.numerator = numerator;
        this.denominator = denominator;
    }

    //----------------------------------------------PUBLIC METHODS------------------------------------------------------
    public Fraction multiply(Fraction fraction) {
        return new Fraction(numerator * fraction.getNumerator(), denominator * fraction.getDenominator());
    }

    public int getNumerator() {
        return numerator;
    }

    public int getDenominator() {
        return denominator;
    }

    @Override
    public String toString() {
        return "Fraction{" +
                "numerator=" + numerator +
                ", denominator=" + denominator +
                '}';
    }
}
